
version 13 
set more off, permanent

* Load balances
	use data/admin_week_data, clear
	keep village hhn_long week balance

* Add covariates
	merge m:1 village hhn_long using data/lab_sample, keepusing(trust_* hh_category)
	drop if hh_category==3
	drop _merge

* make groups
	gen		group_trust0 = 1 if trust_own  >0 & trust_own<.
	replace group_trust0 = 2 if trust_own  ==0
	label define grouplabt 1 "Trust" 2 "No trust" 
	label values group_trust0 grouplabt
	
// another graph - own // Feb 2016 version
gen c2 = 760 if (week>=21& week<=24)
gen c3 = 760 if (week>=19& week<=20)
bysort week: egen temp = mean(balance) if group_trust0 ==1
bysort week: egen temp1 = mean(balance) if group_trust0 ==2
sort week
twoway 	///
	(area c2 week, bcolor(gs15)) ///
	(area c3 week, bcolor(gs15)) ///
	(lpolyci balance week if group_trust0 ==1 , ciplot(rline) clcolor(black) fcolor(black) alc(gs8) lwidth(thin) ) ///
	(lpolyci balance week if group_trust0 ==2 , lp(dash) ciplot(rline) clcolor(black)  fcolor(black) alc(gs8) lwidth(thin)) ///
	(scatter temp week if group_trust0 ==1 , color(black) msize(small) ) ///
	(scatter temp1 week if group_trust0 ==2 , color(black) msize(small) msymbol(T)   ) ///
	if week >18 & week<37, plotregion(color(white)) graphregion(color(white) icolor(white)) xtitle("Weeks") ytitle("Account balance (Rs.)") ///
	legend(order(  /// - "Trust:" - "No trust:"   - " "  ///
				 - "Mean savings:" 7 "" 8 " "   ///
				- "Polynomial regression:" 4 " " 6 " "  ///
				- "95% C.I.:" 3  " " 5 " ") ///
				 subtitle("                                    Trust:                 No trust:", size(small) position(12))  position(12) row(3)   size(small) symplacement(left) keygap(1)) /// textfirst  subtitle("Trust their banker:    Do not trust their banker:", size(small) position(14))
	xlabel(#10, angle(45) ) ylabel(,glcolor(gs15)) ///
	text( 760 20.75 " Phase 2" " Cash - Cash", size(small) placement(e) color(black) justification(left)) ///
	text( 760 18.75 " Lab", size(small) placement(ne) color(black) justification(left))  ///
	title("Trust in own banker") ///
	name(lb1, replace)   // caption(" " "The dots show the mean balance per week.""The lines correspond to the smoothed values of a kernel-weighted local polynomial regression.",  size(vsmall))
drop   c2 c3 temp*

// another graph - other 
gen c2 = 760 if (week>=21& week<=24)
gen c3 = 760 if (week>=19& week<=20)
bysort week: egen temp = mean(balance) if trust_dum_other ==1
bysort week: egen temp1 = mean(balance) if trust_dum_other == 0
sort week
twoway 	///
	(area c2 week, bcolor(gs15)) ///
	(area c3 week, bcolor(gs15)) ///
	(lpolyci balance week if trust_dum_other ==1 , ciplot(rline) clcolor(black) fcolor(black) alc(gs8) lwidth(thin) ) ///
	(lpolyci balance week if trust_dum_other ==0 , lp(dash) ciplot(rline) clcolor(black) fcolor(black) alc(gs8) lwidth(thin))  ///
	(scatter temp week if trust_dum_other ==1 , color(black) msize(small)) ///
	(scatter temp1 week if trust_dum_other ==0 , color(black) msize(small) msymbol(T) ) ///
	if week >18 & week<37, plotregion(color(white)) graphregion(color(white) icolor(white)) xtitle("Weeks") ytitle("Account balance (Rs.)") ///
		legend(order(  /// - "Trust:" - "No trust:"   - " "  ///
				 - "Mean savings:" 7 "" 8 " "   ///
				- "Polynomial regression:" 4 " " 6 " "  ///
				- "95% C.I.:" 3 " " 5 " ") ///
				 subtitle("                                    Trust:                 No trust:", size(small) position(12))  position(12) row(3)   size(small) symplacement(left) keygap(1)) /// textfirst  subtitle("Trust their banker:    Do not trust their banker:", size(small) position(14))
	xlabel(#10, angle(45) ) ylabel(,glcolor(gs15)) ///
	text( 760 20.75 " Phase 2" " Cash - Cash", size(small) placement(e) color(black) justification(left)) ///
	text( 760 18.75 " Lab", size(small) placement(ne) color(black) justification(left))  ///
	title("Trust in other banker") ///
	name(lb2, replace)    //caption(" " "The dots show the mean balance per week.""The lines correspond to the smoothed values of a kernel-weighted local polynomial regression.",  size(vsmall))
drop  c2 c3 temp*	


* COMBINE THE TWO GRAPHS
grc1leg		lb1 lb2 , ycommon legendfrom(lb1)  position(6) span graphregion(color(white) icolor(white)) ro(1)
